package com.hd.trans.share;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;

public class Subtitle implements Parcelable, Cloneable {

    public int id;
    public String startTime;
    public String endTime;
    public String text;
    public long timeIn;
    public long timeOut;
    public int textLength;
    public Subtitle nextSubtitle;
    public int startCount;
    public int endCount;

    public Subtitle() {
    }

    protected Subtitle(Parcel in) {
        id = in.readInt();
        startTime = in.readString();
        endTime = in.readString();
        text = in.readString();
        timeIn = in.readLong();
        timeOut = in.readLong();
        textLength = in.readInt();
        nextSubtitle = in.readParcelable(Subtitle.class.getClassLoader());
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public long getTimeIn() {
        return timeIn;
    }

    public void setTimeIn(long timeIn) {
        this.timeIn = timeIn;
    }

    public long getTimeOut() {
        return timeOut;
    }

    public void setTimeOut(long timeOut) {
        this.timeOut = timeOut;
    }

    public int getTextLength() {
        return textLength;
    }

    public void setTextLength(int textLength) {
        this.textLength = textLength;
    }

    public Subtitle getNextSubtitle() {
        return nextSubtitle;
    }

    public void setNextSubtitle(Subtitle nextSubtitle) {
        this.nextSubtitle = nextSubtitle;
    }

    public int getStartCount() {
        return startCount;
    }

    public void setStartCount(int startCount) {
        this.startCount = startCount;
    }

    public int getEndCount() {
        return endCount;
    }

    public void setEndCount(int endCount) {
        this.endCount = endCount;
    }

    public static final Creator<Subtitle> CREATOR = new Creator<Subtitle>() {
        @Override
        public Subtitle createFromParcel(Parcel in) {
            return new Subtitle(in);
        }

        @Override
        public Subtitle[] newArray(int size) {
            return new Subtitle[size];
        }
    };

    @Override
    public String toString() {
        return "Subtitle [id=" + id + ", startTime=" + startTime + ", endTime=" + endTime + ", text=" + text + ", textLength=" + textLength
                + ", timeIn=" + timeIn + ", timeOut=" + timeOut + "]";
    }

    public static int getTextLength(@NonNull Subtitle subtitle) {
        if (subtitle.text == null) {
            return 0;
        } else {
            return subtitle.text.length();
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(id);
        dest.writeString(startTime);
        dest.writeString(endTime);
        dest.writeString(text);
        dest.writeLong(timeIn);
        dest.writeLong(timeOut);
        dest.writeInt(textLength);
        dest.writeParcelable(nextSubtitle, flags);
    }

    @NonNull
    @Override
    public Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
